from utils.idandmeta import IdAndMeta

from stacking.warehouse.component import Component


class Place(IdAndMeta, Component):
    """Represents a place in a warehouse. This is the base class for entrances, exits, and stacks.
    It defines a small list-like API that can be used by cranes to add or remove items. Place 
    subclasses should redefine the appropriate methods to support the related functionality (e.g. 
    stacks must implement append() and pop())."""
    is_entrance = False
    is_exit     = False
    is_stack    = False
    
    def __init__(self, id, **meta):
        IdAndMeta.__init__(self, id, **meta)
        Component.__init__(self)
        cls = type(self)
        self.is_entrance = cls.is_entrance
        self.is_exit     = cls.is_exit
        self.is_stack    = cls.is_stack
        
    def deepcopy(self, target=None):
        if target is None:
            cls = type(self)
            target = cls.__new__(cls)
        IdAndMeta.deepcopy(self, target)
        Component.deepcopy(self, target)
        target.is_entrance = self.is_entrance
        target.is_exit     = self.is_exit
        target.is_stack    = self.is_stack
        return target
        
    def append(self, item):
        raise NotImplementedError()
        
    def appendleft(self, item):
        raise NotImplementedError()
        
    def pop(self):
        raise NotImplementedError()
        
    def popleft(self):
        raise NotImplementedError()
        
    def insert(self, index, item):
        raise NotImplementedError()
        
    def remove(self, item):
        raise NotImplementedError()
        
        
